//
//  HRInterfaceManager.m
//  haierapp
//
//  Created by Xia Zhiyong on 14-8-21.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "HRInterfaceManager.h"
#import "HRWebService.h"
#import "HRShopCartModel.h"
#import "HRAddressList.h"
#import "HRUser.h"
#import "HRProCategoryList.h"
#import "HRProductList.h"
#import "HRGoodsInfo.h"
#import "HREvaluateList.h"
#import "HRAreaModel.h"
#import "HRCouponListModel.h"
#import "HROrderTracking.h"
#import "HROrderList.h"
#import "HRPointList.h"

#import "HROrderApplyList.h"
#import "HROrderApplyInfo.h"

#import "HRStockCheckList.h"
#import "HRGoodsInfoList.h"

@implementation HRInterfaceManager

+ (void)succeedWithResult:(HRResultModel *)result
                  message:(NSString *)message
                 callback:(interfaceManagerBlock)completion
{
    if (completion == nil) {
        completion = ^(BOOL isSucceed, NSString *message, id data) {};
    }
    if (result.code > 0)
    {
        dispatch_sync(dispatch_queue_create("error", DISPATCH_QUEUE_CONCURRENT), ^()
                      {
                          completion(NO, result.desc, nil);
                      });
    } else {
        dispatch_sync(dispatch_queue_create("dispatch", DISPATCH_QUEUE_CONCURRENT), ^()
                      {
                          completion(YES, message, result.content);
                      });
    }
}

+ (void)failedWithError:(NSError *)error
                message:(NSString *)message
               callback:(interfaceManagerBlock)completion
{
    if (completion == nil) {
        completion = ^(BOOL isSucceed, NSString *message, id data) {};
    }

    if (error.code == -1000)
    {
        completion(NO, error.domain, nil);
    }
    else
    {
        completion(NO, message, nil);
    }
}

#pragma mark -购物车列表
+(void)getProductListByUid:(NSString *)uid completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId", nil];
    
    [HRWebService startRequest:API_SHOP_CAR_LIST
                          body:[dic convertToJsonString]
                          returnClass:[HRShopCartModel class]
                          success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%ld",error.code] callback:completion];
    }];
}

#pragma mark - 分类列表
+(void)getProCategoryList:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken=user.sdToken;
    
    if (sdToken==nil) {
        sdToken=@"";
    }
    
    NSDictionary *paramDic=[[NSDictionary alloc] initWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            nil];
    
    [HRWebService startRequest:API_CATEGORY_LIST body:[paramDic convertToJsonString] returnClass:[HRProCategoryList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%ld",error.code] callback:completion];
    }];

}

#pragma mark - 用户登录、注册
+(void)loginWithUserName:(NSString *)userName withPassword:(NSString *)password completion:(interfaceManagerBlock)completion{
    NSDictionary *dic=[[NSDictionary alloc] initWithObjectsAndKeys:userName,@"userName",@"json",@"type",password,@"password", nil];
    
    [HRWebService startRequest:API_USER_LOGIN body:[dic convertToJsonString] returnClass:[HRUser class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%ld",error.code] callback:completion];
    }];
}

#pragma mark - 用户注册
+(void)registerWithUserName:(NSString *)userName withPassword:(NSString *)password withMobile:(NSString *)mobile completion:(interfaceManagerBlock)completion{
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            userName,@"userName",
                            password,@"password",
                            mobile,@"mobile",
                            nil];
    
    [HRWebService startRequest:API_USER_REGISTER body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
    
}

#pragma mark - 用户注册激活
+(void)registerActivityWithUserName:(NSString *)userName withActivityCode:(NSString *)code completion:(interfaceManagerBlock)completion{
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            userName,@"userName",
                            code,@"activationCode",
                            nil];
    [HRWebService startRequest:API_USER_REGISTER_ACTIVITY body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 重新发送用户注册的激活号码
+(void)activityCodeInRegisterWithUserName:(NSString *)userName withMobile:(NSString *)mobile completion:(interfaceManagerBlock)completion{
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            userName,@"userName",
                            mobile,@"mobile",
                            nil];
    
    [HRWebService startRequest:API_USER_REGISTER_ACTIVITY_CODE body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 添加收获地址
/*
 sdToken	ID全局登录状态凭证		登录凭证
 userId	用户ID
 consignee	收获人姓名
 phone	手机号码
 telephone	固定电话	可选
 zipcode	邮政编码	可选
 email	邮箱	可选
 provinceCode	省编码
 provinceName	省名称
 cityCode	城市编码
 cityName	城市名称
 sectionCode	区/县编码
 sectionName	区/县名称
 addressDetail	详细地址
 addressShort	地址别名	可选
 */
+(void)addReceiveAddress:(NSString *)consignee phone:(NSString *)phone telephone:(NSString *)telephone zipcode:(NSString *)zipcode email:(NSString *)email provinceCode:(NSString *)provinceCode provinceName:(NSString *)provinceName cityCode:(NSString*)cityCode cityName:(NSString*)cityName sectionCode:(NSString *)sectionCode sectionName:(NSString *)sectionName addressDetail:(NSString *)addressDetail addressShort:(NSString *)addressShort completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:sdToken forKey:@"sdToken"];
    [dic setObject:userId forKey:@"userId"];
    [dic setObject:[consignee stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"consignee"];
    [dic setObject:phone forKey:@"phone"];
    if (telephone) {
        [dic setObject:telephone forKey:@"telephone"];
    }
    if (zipcode) {
        [dic setObject:zipcode forKey:@"zipcode"];
    }
    if (email) {
        [dic setObject:email forKey:@"email"];
    }
    [dic setObject:provinceCode forKey:@"provinceCode"];
    [dic setObject:[provinceName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"provinceName"];
    [dic setObject:cityCode forKey:@"cityCode"];
    [dic setObject:[cityName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"cityName"];
    [dic setObject:sectionCode forKey:@"sectionCode"];
    [dic setObject:[sectionName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"sectionName"];
    [dic setObject:[addressDetail stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"addressDetail"];
    if (addressShort) {
        [dic setObject:[addressShort stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"addressShort"];
    }
    
    
    [HRWebService startRequest:API_ADD_ADDRESS body:[dic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"新建地址成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:@"新建地址失败" callback:completion];
    }];
}

#pragma mark -删除收获地址
/*
 sdToken	IDS全局登录状态凭证		登录凭证
 userId     用户ID
 receiveAddressId	收获地址ID
 */
+(void)deleteReceiveAddressById:(NSString *)receiveAddressId completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",receiveAddressId,@"receiveAddressId",nil];
    
    [HRWebService startRequest:API_DEL_ADDRESS body:[dic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"删除地址成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:@"删除地址失败" callback:completion];
    }];
}

#pragma mark - 更新收获地址
/*
 sdToken	ID全局登录状态凭证		登录凭证
 userId	用户ID
 receiveAddressId	收货地址ID
 consignee	收获人姓名
 phone	手机号码
 telephone	固定电话	可选
 zipcode	邮政编码	可选
 email	邮箱	可选
 provinceCode	省编码
 provinceName	省名称
 cityCode	城市编码
 cityName	城市名称
 sectionCode	区/县编码
 sectionName	区/县名称
 addressDetail	详细地址
 addressShort	地址别名	可选
 */
+(void)updateReceiveAddress:(NSString*)consignee receiveAddressId:(NSString*)receiveAddressId phone:(NSString*)phone telephone:(NSString*)telephone zipcode:(NSString*)zipcode email:(NSString*)email provinceCode:(NSString*)provinceCode provinceName:(NSString*)provinceName cityCode:(NSString*)cityCode cityName:(NSString*)cityName sectionCode:(NSString*)sectionCode sectionName:(NSString*)sectionName addressDetail:(NSString*)addressDetail addressShort:(NSString*)addressShort completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:sdToken forKey:@"sdToken"];
    [dic setObject:userId forKey:@"userId"];
    [dic setObject:receiveAddressId forKey:@"receiveAddressId"];
    [dic setObject:[consignee stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"consignee"];
    [dic setObject:phone forKey:@"phone"];
    if (telephone) {
        [dic setObject:telephone forKey:@"telephone"];
    }
    if (zipcode) {
        [dic setObject:zipcode forKey:@"zipcode"];
    }
    if (email) {
        [dic setObject:email forKey:@"email"];
    }
    [dic setObject:provinceCode forKey:@"provinceCode"];
    [dic setObject:[provinceName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"provinceName"];
    [dic setObject:cityCode forKey:@"cityCode"];
    [dic setObject:[cityName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"cityName"];
    [dic setObject:sectionCode forKey:@"sectionCode"];
    [dic setObject:[sectionName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"sectionName"];
    [dic setObject:[addressDetail stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"addressDetail"];
    [dic setObject:[addressShort stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"addressShort"];
    
    [HRWebService startRequest:API_UPDATE_ADDRESS body:[dic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"更新地址成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:@"更新地址失败" callback:completion];
    }];
}

#pragma mark -设置默认收获地址
/*
 sdToken	IDS全局登录状态凭证		登录凭证
 userId	用户ID
 receiveAddressId	收获地址ID		固定传1
 */
+(void)setDefaultAddress:(NSString*)receiveAddressId completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",receiveAddressId,@"receiveAddressId",nil];
    
    [HRWebService startRequest:API_SET_DEFAULT_ADDRESS body:[dic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"设置默认地址成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:@"设置默认地址失败" callback:completion];
    }];
}

#pragma mark -获取收获地址列表
/*
 sdToken	IDS全局登录状态凭证
 userId	用户ID
 */
+(void)getReceiveAddressList:(interfaceManagerBlock)completion{
   
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",nil];
    
    [HRWebService startRequest:API_ALL_ADDRESS
                          body:[dic convertToJsonString]
                   returnClass:[HRAddressList class]
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%ld",error.code] callback:completion];
    }];

}

#pragma mark - 添加收藏
/*
    sdToken: IDS全局登录凭证
    userId: 用户ID
    productId:商品ID
 */
+(void)addFavorite:(NSString *)productId completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            productId,@"productId",
                            sdToken,@"sdToken",
                            userId,@"userId",
                            nil];
    
    [HRWebService startRequest:API_ADD_FAV body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark -删除收藏
/*
 sdToken	IDS全局登录状态凭证
 userId	用户ID
 productId	商品
 */
+(void)deleteFavorite:(NSString*)productId completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",productId,@"productId",nil];
    
    [HRWebService startRequest:API_DEL_FAV
                          body:[dic convertToJsonString]
                   returnClass:nil
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
                           [HRInterfaceManager succeedWithResult:result message:@"成功" callback:completion];
                       } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                           [HRInterfaceManager failedWithError:error message:@"获取收获地址失败" callback:completion];
                       }];

}

#pragma mark - 获取收藏
/*
 sdToken	IDS全局登录状态凭证
 userId	用户ID
 */
+(void)getFavoriteListByUid:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",nil];
    
    [HRWebService startRequest:API_GET_FAV
                          body:[dic convertToJsonString]
                   returnClass:[HRShopCartModel class]
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
                           [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
                       } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                           [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%ld",error.code] callback:completion];
                       }];

}

#pragma mark - 编辑购物车商品数量
/*
 sdToken	IDS全局登录状态凭证		登录凭证
 userId	用户ID
 productId	商品ID
 type	加减类型		增一[0]/减一[1]/直输[2]
 amount	加减数量
 */
+(void)editShopCarCount:(int)type productId:(NSString*)productId nowGoodsAmount:(int)amount completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",productId,@"productId",[NSString stringWithFormat:@"%d",type],@"type",[NSString stringWithFormat:@"%d",amount],@"amount",nil];
    
    [HRWebService startRequest:API_SHOPCART_COUNT
                          body:[dic convertToJsonString]
                   returnClass:[HRShopCartModel class]
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
                           [HRInterfaceManager succeedWithResult:result message:@"成功" callback:completion];
                       } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                           [HRInterfaceManager failedWithError:error message:@"编辑购物车数量失败" callback:completion];
                       }];

    
}

#pragma mark - 添加商品到购物车
/*
 sdToken	IDS全局登录状态凭证		登录凭证
 userId	用户ID
 productId	商品ID
 */
+(void)addProductToShopCar:(NSString *)productId completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken=user.sdToken;
    NSString *userId=user.userId;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            productId,@"productId",
                            nil];
    
    [HRWebService startRequest:API_SHOPCART_ADD_PRODUCT body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 从购物车中删除商品
/*
 sdToken	IDS全局登录状态凭证
 userId	用户ID
 productIds	商品ID集合
 */
+(void)deleteAllSc:(NSString *)productId completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken=user.sdToken;
    NSString *userId=user.userId;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            productId,@"productIds",
                            nil];
    
    [HRWebService startRequest:API_DEL_AUSC body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];

}


#pragma mark - 分类获取商品列表信息

+(void)getProductListByCategoryId:(NSString *)categoryId withPageSize:(int)pageSize withPageNumber:(int)pageNum completion:(interfaceManagerBlock)completion{
    
    NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
    NSString *pageNumStr=[NSString stringWithFormat:@"%d",pageNum];
    
    NSDictionary *paramJSON=[NSDictionary dictionaryWithObjectsAndKeys:
                             categoryId,@"classification1",
                             pageSizeStr,@"pageSize",
                             pageNumStr,@"pageNo",
                             nil];
    
    [HRWebService startRequest:API_PRODUCT_LIST_BY_CATEGORY body:[paramJSON convertToJsonString] returnClass:[HRProductList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"获取成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:@"获取失败" callback:completion];
    }];
    
}

#pragma mark - 搜索条件获取商品列表信息

+(void)getProductListBySearch:(NSString *)searchContent withPageSize:(int)pageSize withPageNumber:(int)pageNum completion:(interfaceManagerBlock)completion{
    
    NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
    NSString *pageNumStr=[NSString stringWithFormat:@"%d",pageNum];
    
    NSDictionary *paramJSON=[NSDictionary dictionaryWithObjectsAndKeys:
                             searchContent,@"searchContent",
                             pageSizeStr,@"pageSize",
                             pageNumStr,@"pageNo",
                             nil];
    
    [HRWebService startRequest:API_PRODUCT_LIST_BY_SEARCH body:[paramJSON convertToJsonString] returnClass:[HRProductList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"获取成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:@"获取失败" callback:completion];
    }];
}

#pragma mark - 获取指定的商品信息

+(void)getProductById:(NSString *)productId completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken;
    NSString *userId;
    NSString *areaId;
    
    if (user==nil) {
        sdToken=@"";
        userId=@"";
        areaId=@"1";
    }else{
        sdToken=user.sdToken;
        userId=user.userId;
        areaId=@"1";
    }
    
    NSDictionary *paramJSON=[NSDictionary dictionaryWithObjectsAndKeys:
                             productId,@"productId",
                             sdToken,@"sdToken",
                             userId,@"userId",
                             areaId,@"areaId",
                             nil];
    
    [HRWebService startRequest:API_PRODUCT_INFO_BY_ID body:[paramJSON convertToJsonString] returnClass:[HRGoodsInfo class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"获取成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 获取多个商品信息通过id列表
+(void)getProductListByIDList:(NSString *)productIdList completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken;
    NSString *userId;
    NSString *areaId;
    
    if (user==nil) {
        sdToken=@"";
        userId=@"";
        areaId=@"1";
    }else{
        sdToken=user.sdToken;
        userId=user.userId;
        areaId=@"1";
    }
    
    NSDictionary *paramJSON=[NSDictionary dictionaryWithObjectsAndKeys:
                             productIdList,@"productId",
                             sdToken,@"sdToken",
                             userId,@"userId",
                             areaId,@"areaId",
                             nil];
    
    [HRWebService startRequest:API_PRODUCT_LIST_BY_IDLIST body:[paramJSON convertToJsonString] returnClass:[HRGoodsInfoList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:@"获取成功" callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 获取指定商品的评价信息
/*
 sdToken: IDS全局登录状态凭证
 productId: 商品ID
 pageSize: 每页显示多少条
 pageNo: 显示第几页
 */
+(void)getEvaluateByProductId:(NSString *)productId withPageSize:(int)pageSize withPageNumber:(int)pageNum completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    
    NSString *pageSizeStr=[NSString stringWithFormat:@"%d",pageSize];
    NSString *pageNumStr=[NSString stringWithFormat:@"%d",pageNum];
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            productId,@"productId",
                            pageSizeStr,@"pageSize",
                            pageNumStr,@"pageNo",
                            user.sdToken,@"sdToken",
                            nil];
    
    [HRWebService startRequest:API_PRODUCT_EVALUATE_BY_ID body:[paramDic convertToJsonString] returnClass:[HREvaluateList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}


#pragma mark - 省、市、区
//获取所有的省
/*
 sdToken	IDS全局登录状态凭证
 */
+(void)getProvinceList:(interfaceManagerBlock)completion{
   
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;

    NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:sdToken,@"sdToken", nil];
    [HRWebService startRequest:API_GET_PROVINCE body:[dic convertToJsonString] returnClass:[HRAreaModel class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

//获取省下的市
/*
 sdToken	IDS全局登录状态凭证
 Code	    省份ID
 */
+(void)getCityList:(NSString *)Code completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",Code,@"code", nil];
    [HRWebService startRequest:API_GET_CITY body:[dic convertToJsonString] returnClass:[HRAreaModel class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
    
}

//获取市下的区
/*
 sdToken	IDS全局登录状态凭证
 code	市ID
 */
+(void)getCountyList:(NSString*)Code completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;

    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",Code,@"code", nil];
    [HRWebService startRequest:API_GET_COUNTY body:[dic convertToJsonString] returnClass:[HRAreaModel class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 获取优惠券列表
/*
 sdToken	IDS全局登录状态凭证
 userId	用户ID
 */
+(void)getCouponList:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",nil];
    [HRWebService startRequest:API_COUPON_LIST body:[dic convertToJsonString] returnClass:[HRCouponListModel class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%ld",error.code] callback:completion];
    }];
}

#pragma mark - 查看订单进度
/*
 sdToken:IDS全局登录凭证
 userId
 orderNo
 */
+(void)getOrderTrackingById:(NSString *)orderId completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            orderId,@"orderNo",
                            nil];
    
    [HRWebService startRequest:API_ORDER_TRACKING body:[paramDic convertToJsonString] returnClass:[HROrderTracking class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 获取所有订单
/*
 sdToken
 userId
 */
+(void)getOrderListWithCompletion:(interfaceManagerBlock)completion{

    HRUser *user=[HRCommonData shareCommonData].curUser;
 
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            user.sdToken,@"sdToken",
                            user.userId,@"userId",
                            nil];
    
    [HRWebService startRequest:API_GET_ORDERS body:[paramDic convertToJsonString] returnClass:[HROrderList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%ld",error.code] callback:completion];
    }];
}

#pragma mark - 创建新订单

/*
 sdToken	IDS全局登录状态凭证	可选	登录凭证
 userId	用户ID
 userName	用户name
 addressId	收货地址ID
 paymentMethod	支付方式
 distributionTime	送货时间类型		1.不限送货时间【0-周一至周日】
 2.工作日送货周一至周五【1-上午（9点至12点）,2-下午（12点至18点）】
 3.周末节假日送货周六至周日【3-上午（9点至12点）,4-下午（12点至18点）】
 invoiceType	发票类型		0个人1增值税发票
 invoiceName	发票头		普票默认“个人”,户头  增票默认公司名称
 couponsId	优惠劵ID
 isCoupon	使用优惠劵（现在还没有）
 remark	订单附言
 distributionType	送货方式		默认0
 productList	商品对象		List

 */

+(void)createOrder:(NSString*)addressId paymentMethod:(NSString*)paymentMethod distributionTime:(int)distributionTime invoiceType:(int)invoiceType invoiceName:(NSString*)invoiceName isCoupon:(int)isCoupon couponsId:(NSString*)couponsId remark:(NSString*)remark distributionType:(int)distributionType productList:(NSArray*)productList isActivity:(int)isActivity activityId:(NSString *)activityId completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSString *userName = user.userName;
    
    invoiceName=[invoiceName stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSMutableDictionary *dic = [[NSMutableDictionary alloc] init];
    [dic setObject:sdToken forKey:@"sdToken"];
    [dic setObject:userId forKey:@"userId"];
    [dic setObject:userName forKey:@"userName"];
    [dic setObject:addressId forKey:@"addressId"];
    [dic setObject:paymentMethod forKey:@"paymentMethod"];
    [dic setObject:[NSString stringWithFormat:@"%d",distributionTime] forKey:@"distributionTime"];
    [dic setObject:[NSString stringWithFormat:@"%d",invoiceType] forKey:@"invoiceType"];
    [dic setObject:invoiceName forKey:@"invoiceName"];
    [dic setObject:[NSString stringWithFormat:@"%d",isCoupon] forKey:@"isCoupon"];
    [dic setObject:couponsId forKey:@"couponsId"];
    [dic setObject:remark forKey:@"remark"];
    [dic setObject:[NSString stringWithFormat:@"%d",distributionType] forKey:@"distributionType"];
    
    if (isActivity==0) {
        [dic setObject:productList forKey:@"productList"];
    }else{
        [dic setObject:@"" forKey:@"productList"];
    }
    
    [dic setObject:[NSString stringWithFormat:@"%d",isActivity] forKey:@"isActivity"];
    
    if (activityId==nil) {
        activityId=@"";
    }
    [dic setObject:activityId forKey:@"activityId"];
    
    [HRWebService startRequest:API_CREATE_ORDER body:[dic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}


#pragma mark -订单详情
/*
 sdToken	IDS全局登录状态凭证
 userId	用户ID
 orderNo	订单号
 */
+(void)getOrderDetails:(NSString*)orderNo completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
     NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:orderNo,@"orderNo",sdToken,@"sdToken",userId,@"userId",nil];
    
    [HRWebService startRequest:API_ORDER_DEATAIL body:[dic convertToJsonString] returnClass:[HROrder class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];

}

#pragma mark - 取消订单
/*
 sdToken
 userId
 orderNo
 cancelReason
 */
+(void)cancelOrderById:(NSString *)orderId andReason:(NSString *)reason completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    reason=[reason stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            orderId,@"orderNo",
                            reason,@"cancelReason",
                            user.sdToken,@"sdToken",
                            user.userId,@"userId",
                            nil];
    [HRWebService startRequest:API_ORDER_CANCEL body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
    
}


#pragma mark - 获取产品列表
/*
 type:产品列表类型 （分类ID获取、关键字获取）
 conten:关键字 或 分类ID
 pageSize:每页显示的信息数
 pageNum:当前获取的页数
 orderType:排序字段 （时间、销量、好评）
 order:排序规则 (1升序 2降序)
 */
+(void)getProductListByType:(TYPE_PRODUCT_LIST)type withContent:(NSString *)content withPageSize:(NSString *)pageSize withPageNumber:(NSString *)pageNum withOrderType:(ORDER_TYPE_PRODUCT_LIST)orderType withOrderBy:(int)order completion:(interfaceManagerBlock)completion{
    NSString *sdToken=@"";
    
    //NSString *typeStr=[NSString stringWithFormat:@"%d",type];
    NSString *orderTypeStr=[NSString stringWithFormat:@"%d",orderType];
    NSString *orderStr=[NSString stringWithFormat:@"%d",order];
    
    NSMutableDictionary *paramDic=[[NSMutableDictionary alloc]initWithObjectsAndKeys:
                                   sdToken,@"sdToken",
                                   pageSize,@"pageSize",
                                   pageNum,@"pageNo",
                                   orderTypeStr,@"orderType",
                                   orderStr,@"orderBy",
                                   nil];
    
    if (type==TYPE_PRODUCT_LIST_BY_ID) {
        [paramDic setValue:content forKey:@"classification1"];
        [paramDic setValue:@"" forKey:@"searchContent"];
    }else{
        content=[content stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        [paramDic setValue:content forKey:@"searchContent"];
        [paramDic setValue:@"" forKey:@"classification1"];
    }
    
    [HRWebService startRequest:API_PRODUCT_LIST body:[paramDic convertToJsonString] returnClass:[HRProductList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
    
}

#pragma mark - 确认收货
+(void)receiptOrder:(NSString *)orderId completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken=user.sdToken;
    NSString *userId=user.userId;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            orderId,@"orderNo",
                            sdToken,@"sdToken",
                            userId,@"userId",
                            nil];
    
    [HRWebService startRequest:API_ORDER_RECEIPT body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

#pragma mark - 获取售后订单列表
+(void)getOrderListApply:(interfaceManagerBlock) completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    
    NSString *sdToken=user.sdToken;
    NSString *userId=user.userId;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            nil];
    
    [HRWebService startRequest:API_GET_APPLY_ORDER_LIST body:[paramDic convertToJsonString] returnClass:[HROrderApplyList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%d",error.code] callback:completion];
    }];
    
}

#pragma mark - 申请售后
+(void)repairOrderApplyByOrder:(NSString *)orderId withReason:(NSString *)reason withType:(ORDER_APPLY_TYPE)type withAddrType:(ORDER_APPLY_ADDR_TYPE)addrType withProductId:(NSString *)productId withProductCount:(NSString *)productCount completion:(interfaceManagerBlock)completion{
    
    HRUser *user=[HRCommonData shareCommonData].curUser;
    
    NSString *sdToken=user.sdToken;
    NSString *userId=user.userId;
    NSString *userName=user.userName;
    
    NSString *typeStr=[NSString stringWithFormat:@"%d",type];
    NSString *addrTypeStr=[NSString stringWithFormat:@"%d",addrType];
    
    NSArray *productInfo=@[@{@"productId":productId,
                             @"goodsAmount":productCount
                             }];
    
    reason=[reason stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            orderId,@"orderNo",
                            userName,@"userName",
                            typeStr,@"radio",
                            reason,@"remakr",
                            addrTypeStr,@"saddr",
                            productInfo,@"productInfo",
                            nil];
    
    [HRWebService startRequest:API_ORDER_REPAIR_APPLY body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
    
}

#pragma mark - 查看售后详情
+(void)getOrderApplyDetailById:(NSString *)serviceNo completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    
    NSString *sdToken=user.sdToken;
    NSString *userId=user.userId;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            serviceNo,@"serviceNo",
                            nil];
    
    [HRWebService startRequest:API_ORDER_REPAIR_DETAILS body:[paramDic convertToJsonString] returnClass:[HROrderApplyInfo class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}


#pragma mark - 获取积分信息
+(void)getTotalPointsById:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId", nil];
    [HRWebService startRequest:API_GET_POINTS
                          body:[dic convertToJsonString]
                   returnClass:nil
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
                           //保存用户积分
                           HRUser *userInfo=[HRCommonData shareCommonData].curUser;
                           userInfo.userScore = [NSString stringWithFormat:@"%@",[result.content objectForKey:@"total"] ];
                           [HRCommonData shareCommonData].isUserScoreChanged = NO;
                           
                           [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
                       } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                           [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%d",error.code] callback:completion];
                       }];

}

+(void)selectPointsItemsById:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId", nil];
    [HRWebService startRequest:API_GET_POIGTS_LIST
                          body:[dic convertToJsonString]
                   returnClass:[HRPointList class]
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
                            [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
                       } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                           [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%d",error.code] callback:completion];
                       }];

}

#pragma mark - 新增支付单
/*
 sdToken	IDS全局登录状态凭证	可选	登录凭证
 userId	用户ID
 orderIdList	订单号		多个订单用，隔开
 payMoney	支付金额
 paymentNo	支付方式		kjt或alipay
 */
+(void)savePayBill:(NSString*)orderIdList payMoney:(NSString*)payMoney paymentNo:(NSString*)paymentNo completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
     NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",orderIdList,@"orderIdList",payMoney,@"payMoney",paymentNo,@"paymentNo", nil];
    
    [HRWebService startRequest:API_PAY_BILL
                          body:[dic convertToJsonString]
                   returnClass:nil
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
                           [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
                       } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                           [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%d",error.code] callback:completion];
                       }];

}

#pragma mark - 更改订单状态
/*
 sdToken	IDS全局登录状态凭证	可选
 userId	用户ID
 payNo	支付单编号
 message	支付返回消息	可选
 */
+(void)updateOrderPayState:(NSString*)payNo message:(NSString*)message completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken = user.sdToken;
    NSString *userId = user.userId;
    NSDictionary *dic = [[NSDictionary alloc] initWithObjectsAndKeys:sdToken,@"sdToken",userId,@"userId",payNo,@"payNo",message,@"message", nil];
    
    [HRWebService startRequest:API_UPDATE_ORDER_STATE
                          body:[dic convertToJsonString]
                   returnClass:nil
                       success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
                           [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
                       } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
                           [HRInterfaceManager failedWithError:error message:[NSString stringWithFormat:@"%d",error.code] callback:completion];
                       }];
}

#pragma mark - 校验商品库存
/*
 productId:商品ID
 sectionCode:区县国标码
 */
+(void)checkStockByProductId:(NSArray *)productList withSectionCode:(NSString *)code  completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    NSString *sdToken=user.sdToken;
    NSString *userId=user.userId;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            productList,@"productList",
                            code,@"sectionCode",
                            nil];
    
    [HRWebService startRequest:API_CHECK_STOCK body:[paramDic convertToJsonString] returnClass:[HRStockCheckList class] success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
    
    
}

#pragma mark - 评价订单商品
/*
 orderNo:订单号
 productList:商品评价信息列表
 */
+(void)evaluateOrderProducts:(NSArray *)productList completion:(interfaceManagerBlock)completion{
    HRUser *user=[HRCommonData shareCommonData].curUser;
    
    NSString *userId=user.userId;
    NSString *sdToken=user.sdToken;
    
    NSDictionary *paramDic=[NSDictionary dictionaryWithObjectsAndKeys:
                            sdToken,@"sdToken",
                            userId,@"userId",
                            productList,@"productList",
                            nil];
    
    [HRWebService startRequest:API_EVALUATE_ORDER_PRODUCTS body:[paramDic convertToJsonString] returnClass:nil success:^(AFHTTPRequestOperation *operation, HRResultModel *result) {
        [HRInterfaceManager succeedWithResult:result message:result.desc callback:completion];
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        [HRInterfaceManager failedWithError:error message:error.description callback:completion];
    }];
}

@end
